package com.wanxi.web.controller;

import com.wanxi.product.service.api.query.admin.SkuQuery;
import com.wanxi.product.service.api.query.admin.TagQuery;
import com.wanxi.product.service.api.query.admin.TypeQuery;
import com.wanxi.product.service.api.result.CommonResult;
import com.wanxi.product.service.api.vo.admin.*;
import com.wanxi.web.service.product.ProductAdminWebService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * ClassName: AdminProductController
 * Description: 管理员商品
 * date: 2022/1/13 11:14
 *
 * @author lxl
 * @version 1.0
 * @since JDK 1.8
 */
@Api(tags = "管理员商品接口")
@RestController
@RequestMapping("admin/product")
public class AdminProductController {

    @Resource
    private ProductAdminWebService productWebService;

    @ApiOperation("添加一二级分类")
    @PostMapping("/type/add")
    public CommonResult<Long> adminAddType(TypeAddInVo typeAddInVo) {
        return productWebService.adminAddType(typeAddInVo);
    }

    @ApiOperation("获取一二级分类列表")
    @GetMapping("/type/findAll")
    public CommonResult<TypeFindAllOutVo> adminFindAllType(TypeQuery firstTypeQuery) {
        return productWebService.adminFindAllType(firstTypeQuery);
    }

    @ApiOperation("根据id查询分类")
    @GetMapping("/type/findById")
    public CommonResult<TypeFindByIdOutVo> adminFindTypeById(Long id) {
        return productWebService.adminFindTypeById(id);
    }

    @ApiOperation("修改分类")
    @PutMapping("/type/update")
    public CommonResult adminUpdateType(TypeUpdateInVo typeUpdateInVo) {
        return productWebService.adminUpdateType(typeUpdateInVo);
    }

    @ApiOperation("删除分类")
    @PutMapping("/type/delete")
    public CommonResult adminDeleteType(Long id) {
        return productWebService.adminDeleteType(id);
    }

    @ApiOperation("获取sku列表")
    @GetMapping("/sku/findAll")
    public CommonResult<List<SkuFindAllOutVo>> adminFindAllSku(SkuQuery skuQuery) {
        return productWebService.adminFindAllSku(skuQuery);
    }

    @ApiOperation("修改sku状态")
    @PutMapping("/sku/update")
    public CommonResult updateSku(SkuUpdateInVo skuUpdateInVo) {
        return productWebService.adminUpdateSku(skuUpdateInVo);
    }

    @ApiOperation("逻辑删除sku")
    @PutMapping("/sku/delete")
    public CommonResult adminDeleteSkuById(Long id) {
        return productWebService.adminDeleteSkuById(id);
    }

    @ApiOperation("添加标签")
    @PostMapping("/tag/add")
    public CommonResult adminAddTag(TagAddInVo tagAddInVo) {
        return productWebService.adminAddTag(tagAddInVo);
    }

    @ApiOperation("获取标签列表")
    @GetMapping("/tag/findAll")
    public CommonResult adminFindTagAll(TagQuery tagQuery) {
        return productWebService.adminFindTagAll(tagQuery);
    }

    @ApiOperation("逻辑删除标签")
    @PutMapping("/tag/delete")
    public CommonResult adminDeleteTagById(@RequestParam(name = "tagId") Long tagId) {
        return productWebService.adminDeleteTagById(tagId);
    }
}
